package com.lashou.chunshen.lashoutuangou.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.lashou.chunshen.lashoutuangou.tools.L;

import java.util.List;

/**
 * 首页ViewPager
 * Created by momo on 2016/9/5.
 */

public class MyViewPagerAdapter01<T extends View> extends PagerAdapter {
    private  List<T>  mViewList;




    public MyViewPagerAdapter01(List<T> mViewList) {
        this.mViewList = mViewList;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        L.d("%%%%%%%%%%","container.getChildCount()="+container.getChildCount()+"position="+position);
        container.removeView(mViewList.get(position));
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        L.d("------------------","container.getChildCount()="+container.getChildCount()+"position="+position);
        container.addView(mViewList.get(position));
        return (mViewList.get(position));
    }


    @Override
    public int getCount() {
        //Log.d("Viewpager========",mViewList.size()+"");
        if (mViewList == null) {
            return 0;
        } else {
            return mViewList.size();
        }
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}
